<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">

            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>是否菜单
                </label>
                <div class="layui-input-block">
                    <input type="radio" name="type" value="menu" title="是" checked="">
                    <input type="radio" name="type" value="file" title="否">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>父ID</label>
                <div class="layui-input-inline">
                    <select id="pid" name="pid" class="valid">
                        <option value="0">无</option>
                        {{range .ruleList}}
                            <option value="{{.Id}}">{{.Name}}</option>
                        {{end}}
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    规则
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="skip_url" name="skip_url" required="" lay-verify="required" placeholder="如：/admin/sys"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    仅做层级显示无需匹配空制器和方法
                </div>
            </div>

            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>标题
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="name" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">图标</label>
                <div class="layui-input-inline">
                    <input type="text" name="icon" id="icon" placeholder="请输入图标代码" autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label" id="iconlabel" style="text-align: left;"><a target="_blank" href="/admin/rule/icon">点击查看图标</a></label>
            </div>

            <div class="layui-form-item layui-form-text">
                <label for="desc" class="layui-form-label">
                    备注
                </label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" id="remark" name="remark" class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>权重
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="weigh" name="weigh" required="" lay-verify="required"
                           autocomplete="off" class="layui-input" value="0" >
                </div>
            </div>

            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>状态
                </label>
                <div class="layui-input-block">
                    <input type="radio" name="status" value="1" title="正常" checked="">
                    <input type="radio" name="status" value="2" title="禁用">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="add" lay-submit="">
                    增加
                </button>
            </div>
        </form>
    </div>
</div>
<script>layui.use(['form', 'layer'],
        function() {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            //自定义验证规则
            form.verify({

            });

            //监听提交
            form.on('submit(add)',
                function(data) {
                    console.log(data)
                    request_post("/admin/rule/add",data.field).then(function (data) {
                        layer.alert("增加成功", {
                                icon: 6
                            },
                            function() {
                                //关闭当前frame
                                xadmin.close();

                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                    },function (error) {
                        msg_error(error.msg)
                    })
                    return false;
                });

        });</script>